package com.us.usws.support.uitls;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.us.usws.common.SiteConstants;
import com.us.usws.model.domain.ipodium.IpodiumUser;

public class SiteWebContext extends WebContext {

	public SiteWebContext(HttpServletRequest request, HttpServletResponse response) {
		super(request, response);
	}

	/**
	 * get box sn
	 * @return
	 */
	public String getEpUserId() {
		String boxsn = getRequest().getHeader(SiteConstants.WS_HEADER_USERID_NAME);
		return boxsn;
	}

	/**
	 * get token
	 * @return
	 */
	public String getEpToken() {
		String token = getRequest().getHeader(SiteConstants.WS_HEADER_TOKEN_NAME);
		return token;
	}

	/**
	 * get ipodium user
	 * @return
	 */
	public IpodiumUser getIpodiumUser() {
		return (IpodiumUser) getSession().getAttribute(SiteConstants.SESSION_KEY_IPODIUM_USER);
	}

	/**
	 * set ipodium user
	 * @param u
	 */
	public void setIpodiumUser(IpodiumUser u) {
		getSession().setAttribute(SiteConstants.SESSION_KEY_IPODIUM_USER, u);
	}

	/**
	 * logout ipodium user
	 */
	public void logoutIpodiumUser() {
		getSession().removeAttribute(SiteConstants.SESSION_KEY_IPODIUM_USER);
	}

	/**
	 * whether ipodium user login
	 * @return
	 */
	public boolean isIpodiumLogin() {
		return getIpodiumUser() == null ? false : true;
	}

}
